package com.ccibe.g16system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccibe.g16system.mapper.MerchantMapper;
import com.ccibe.g16system.pojo.Merchant;
import com.ccibe.g16system.pojo.form.LoginForm;
import com.ccibe.g16system.service.MerchantService;
import com.ccibe.g16system.utils.SecretUtil;
import org.springframework.stereotype.Service;

@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant>
        implements MerchantService {

    @Override
    public Merchant login(LoginForm form) {
        LambdaQueryWrapper<Merchant> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Merchant::getAccount, form.getUsername())
                .eq(Merchant::getPassword, SecretUtil.md5Encode(form.getPassword()));
        return baseMapper.selectOne(wrapper);
    }
}
